from multiprocessing import Process


class Process_application():

    def __init__(self):
        self.process = []

    def choice_process(self, sign):
        if sign == 4:
            print("使用四进程")
        else:
            print("使用二进程（默认）")

    # 双-进程编写
    def double_process(self, target, files, output):
        mid = len(files) // 2
        files_1 = files[:mid]
        files_2 = files[mid:]
        return [
            Process(target=target, args=(files_1, output)),
            Process(target=target, args=(files_2, output))
        ]

    # 四-进程编写
    def four_process(self, target, files, output):
        chunk_size = len(files) // 4
        files_1 = files[:chunk_size]
        files_2 = files[chunk_size:2 * chunk_size]
        files_3 = files[2 * chunk_size:3 * chunk_size]
        files_4 = files[3 * chunk_size:]
        return [
            Process(target=target, args=(files_1, output)),
            Process(target=target, args=(files_2, output)),
            Process(target=target, args=(files_3, output)),
            Process(target=target, args=(files_4, output))
        ]
























